package cn.tedu.charging.user.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;

/**
 * 验证框架的配置
 */
@Configuration
public class ValidationConfiguration {

    @Bean
    public javax.validation.Validator validator(){
        return Validation
                .byProvider(HibernateValidator.class)
                .configure()
                .failFast(true) // 快速失败 一个检查不通过,就返回,不会继续检查
                .buildValidatorFactory()
                .getValidator();
    }
}
